Skip to content

Fix HUNT/USDC zap reverts + Trading Widget UX#446

Merged
realproject7 merged 1 commit intomainfrom
task/445-trading-widget-fixes
Mar 23, 2026
Merged

Fix HUNT/USDC zap reverts + Trading Widget UX#446
realproject7 merged 1 commit intomainfrom
task/445-trading-widget-fixes

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Bug fix: HUNT zap reverted due to OOG (3M gas limit, needs 3.05M). Increased to 5M.
  • Bug fix: USDC zap reverted due to wrong action constants in contract. Updated ZAP_PLOTLINK to redeployed contract 0x04f557F8D2806B34FC832a534c08DF514D4dfEeF.
  • UX: Balance moved below PAY WITH selector
  • UX: MAX button added on buy tab (ETH reserves 0.001 for gas)
  • UX: Label changed to "Story tokens to buy"
  • UX: Section title changed to "Trade to Support" with tooltip explaining 5% creator royalty
  • UX: Insufficient balance warning verified for all 4 token options

Fixes #253

Test plan

  • Frontend builds (next build)
  • Contract estimates verified for all 4 input tokens
  • Manual test: HUNT zap completes without OOG
  • Manual test: USDC zap completes without revert
  • Visual: Balance shows below PAY WITH
  • Visual: MAX button on buy tab works
  • Visual: Tooltip on "Trade to Support" header

🤖 Generated with Claude Code

Bug fixes:
- Update ZAP_PLOTLINK to 0x04f557F8D2806B34FC832a534c08DF514D4dfEeF
  (fixed multi-hop action constants in contract)
- Increase gas limit from 3M to 5M (HUNT MCV2 double-mint needs ~3.05M)

UX changes:
- Move balance display below PAY WITH token selector
- Add MAX button on buy tab (ETH reserves 0.001 for gas)
- Rename "Tokens to buy" -> "Story tokens to buy"
- Change "Trade" -> "Trade to Support" with hover tooltip
  explaining 5% creator royalty
- Insufficient balance warning works for all 4 token options

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@project7-interns project7-interns self-requested a review March 23, 2026 09:26
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b Code Review — PR #446

Verdict: APPROVE

Reviewed all 3 changed files (constants.ts, zap.ts, TradingWidget.tsx). Here are my findings:

1. ZAP_PLOTLINK address update

0x04f557F8D2806B34FC832a534c08DF514D4dfEeF — correctly updated on mainnet only; testnet remains zeroed out. Checksum format looks valid. OK.

2. Gas limit 3M → 5M

Reasonable. PR description states HUNT MCV2 double-mint needs ~3.05M, so 3M was barely insufficient. 5M provides ~65% headroom which is standard practice for multi-hop DeFi transactions. The gas param is a limit (unused gas is refunded), so the only downside is a slightly higher upfront ETH reservation — negligible for users. OK.

3. Balance display below PAY WITH selector

Moved correctly. The balance and insufficient-balance warning now render inside the tab === "buy" && isZapAvailable block, directly under the token buttons. For sell tab and non-zap buy, the original position (below the input) is preserved via (tab === "sell" || !isZapAvailable) guards. Logic is clean. OK.

4. MAX button (buy tab)

  • ETH: ethBal - ETH_GAS_BUFFER (0.001 ETH) — good, prevents users from draining their entire balance and failing on gas. The constant is correctly defined as BigInt("1000000000000000") (10^15 wei = 0.001 ETH). Floor at zero handled.
  • USDC/HUNT: reads balanceOf from erc20BalanceToken — correct, uses full balance.
  • PLOT: reads balanceOf from PLOT_TOKEN — correct.
  • All paths call getZapQuote with "exact-input" to convert the pay-token balance into story tokens, then set the amount field. This is the right direction (user sees output tokens).
  • Edge case: maxBalance <= 0 returns early — good.
  • Error handling: silent catch — acceptable for a convenience button; user can still type manually.
  • One minor note: The USDC/HUNT path does a fresh readContract for balance instead of using the already-fetched balance state variable. This means a redundant RPC call but ensures the value is current. Acceptable trade-off.

OK.

5. Label "TOKENS TO BUY" → "STORY TOKENS TO BUY"

Only on buy tab; sell tab remains "Tokens to sell". OK.

6. "Trade" → "Trade to Support" + tooltip

Tooltip uses CSS-only hover (group-hover:block) — no JS state needed, clean approach. Tooltip text accurately describes the 5% creator royalty. pointer-events-none prevents tooltip from stealing hover. z-10 ensures it renders above other elements. OK.

7. Insufficient balance warning

For buy tab with zap: rendered below the PAY WITH selector.
For sell tab / non-zap buy: rendered below the input field.
Guards (tab === "sell" || !isZapAvailable) are consistent between balance display and warning. OK.

8. Security check

  • No hardcoded private keys or secrets.
  • Contract address is a deploy-time constant — appropriate.
  • Gas buffer is a sensible constant, not a magic number in-line.
  • Arrow comment change ( to ->) is cosmetic only, no logic change.
  • publicClient.readContract calls use typed ABIs — safe.

9. Code quality

  • useCallback dependency arrays look complete and correct.
  • pr-14 class applied to both buy and sell tabs now (for MAX button spacing) — correct.
  • No unused imports or dead code introduced.
  • Single commit, well-structured message.

No issues found. Approved.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b Review: PR #446 — Trading widget bug fix + UX

APPROVED

Bug fixes:

  • ZAP_PLOTLINK address updated to 0x04f557F8D2806B34FC832a534c08DF514D4dfEeF
  • Gas limit 3M → 5M reasonable (HUNT needs ~3.05M, unused gas refunded)

UX changes — all verified:

  • Balance moved below PAY WITH selector
  • MAX button: ETH with 0.001 gas buffer, USDC/HUNT full balance, all use getZapQuote
  • Label: "Story tokens to buy" ✅
  • "Trade to Support" + tooltip with 5% royalty description ✅
  • Insufficient balance warnings work for all 4 tokens

No security issues, clean implementation.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The widget fixes are coherent, the root-cause contract address update is in place, and the PR is now green. I don't see any remaining correctness or UX blockers.

Findings

  • [resolved] Remaining CI gate is green.
    • File: src/components/TradingWidget.tsx:151
    • Suggestion: None.

Decision

Approving because the bug fixes and UX updates are correct and the PR passes checks.

@realproject7 realproject7 merged commit 4e3917b into main Mar 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants